<?php
/**
 * 首页控制器
 */
class Index extends BaseAction
{
	/**
	 * 初始化
	 */
	public function _init()
	{

	}

	/**
	 * 默认动作
	 */
	protected function _default()
	{
		#获取到新闻信息
		$arrNews = $this->get_news_info(4);
		$this->assign('arrNews',$arrNews);
		#获取banner图片
		$arrBannerImages = $this->get_banner_images('');
		$this->assign('arrBannerImages',$arrBannerImages);
		#获取到知之信息
		$arrKnows = $this->get_knows_info(4);
		$this->assign('arrKnows',$arrKnows);
		
		$strSeoTitle =   '铝扣板天花吊顶|钢板天花吊顶|挂搭板天花吊顶|半明半暗天花吊顶|金属天花吊顶|金属踢脚线|金属墙板-康纳天花';
		$strSeoKeywords = "铝扣板天花吊顶，钢板天花吊顶，挂搭板天花吊顶，半明半暗天花吊顶，金属天花吊顶，金属踢脚线，金属墙板";
		$strSeoDesc =  '康纳天花华南建材十大品牌为您提供:铝扣板天花吊顶,钢板天花吊顶,挂搭板天花吊顶,半明半暗天花吊顶,金属天花吊顶,金属踢脚线,金属墙板;我们秉承"技术创新,质量优先的原则"为用户做更好的天花产品';
		$this->assign('seo_title',$strSeoTitle);//seo标题
		$this->assign('seo_keywords',$strSeoKeywords);//seo关键字
		$this->assign('seo_desc',$strSeoDesc);//seo描述
		$this->tpl_full_path('/front/index/index');
	}
	
	/**
	*获取到新闻信息
	**/
	private function get_news_info($limit = 4){
		$sql = 'select id,title,dateline from news where checkState = 2 order by dateline desc limit  '.$limit;
		$arrData = DB::select($sql);
		if($arrData){
			return $arrData;
		}else{
			return false;
		}
	}
	
	
	/**
	*获取到banner图片
	**/
	private function get_banner_images($limit = 5){
		if(empty($limit)){
		   $sql = 'select id,title,url,position,img from banner where  checkState = 2 order by id desc';
		   $arrData = DB::select($sql);
		}else{
		  $sql = 'select id,title,url,position,img from banner where  checkState = 2 and position = 1 order by id desc limit  '.$limit;
		   $arrData = DB::select($sql);
		}
		if($arrData){
			foreach($arrData as $k=>$v){
				if($v['URL']){
				  $url = $v['URL'];
				  $arrRep = array('http://','http','//');
				  $url = str_replace($arrRep,array('','',''),$url);
				  $arrData[$k]['URL'] = 'http://'.$url;
				}
			}
			return $arrData;
		}else{
			return false;
		}
	}
	
	
	
	/**
	*获取到知之信息
	**/
	private function get_knows_info($limit = 4){
		$sql = 'select id,title,dateline from knows where checkState = 2 order by dateline desc limit  '.$limit;
		$arrData = DB::select($sql);
		if($arrData){
			return $arrData;
		}else{
			return false;
		}
	}




}
?>
